package MicroSpring.aopProxy.pjp;

import MicroSpring.exception.BeansException;

import java.lang.annotation.Documented;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * *
 * * 用于获取原目标方法的执行
 */
public class PjpImpl implements ProceedingJoinPoint{
    private Method method;
    private Object object;
    private Object[] args;
    public PjpImpl(Method method, Object object,Object []args) {
        this.method = method;
        this.object = object;
        this.args=args;
    }

    @Override
    public Object proceed()  {
        try {
            return method.invoke(object,args);
        } catch (InvocationTargetException |  IllegalAccessException e ) {
            throw new BeansException("反射调用原方法异常");
        }
    }

    @Override
    public Object proceed(Object[] var1) throws Throwable {
        return method.invoke(object,var1);
    }
}
